package com.study.english.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.english.pojo.vo.PlStudyPlanVo;
import com.study.english.result.Result;
import com.study.english.service.IPlStudyPlanService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import com.study.english.domain.PlStudyPlan;

import org.springframework.web.bind.annotation.*;

/**
 * 学习计划
 *
 * @author wf
 * @description 针对表【pl_study_plan(学习计划)】的数据库操作Controller
 * @createDate 2024-06-27 15:28:53
 */
@RestController
@RequestMapping("plStudyPlan")
public class PlStudyPlanController {

    @Autowired
    private IPlStudyPlanService plStudyPlanService;


    /**
     * 新增:学习计划
     */
    @PostMapping("addPlStudyPlan")
    public Result addPlStudyPlan(@RequestBody PlStudyPlanVo plStudyPlanVo) {
        plStudyPlanService.addPlStudyPlan(plStudyPlanVo);
        return Result.success();

    }


    /**
     * 分页查询:学习计划
     */
    @PostMapping("getPlStudyPlanPageList")
    public Result getPlStudyPlanPageList(@RequestBody PlStudyPlanVo plStudyPlanVo) {

        IPage<PlStudyPlanVo> page = new Page<>(plStudyPlanVo.getPageNum(), plStudyPlanVo.getPageSize());
        IPage<PlStudyPlanVo> list = plStudyPlanService.getPlStudyPlanPageList(page, plStudyPlanVo);
        return Result.success(list);
    }


    /**
     * 不分页查询:学习计划
     */

    @PostMapping("getPlStudyPlanList")
    public Result getPlStudyPlanList(@RequestBody PlStudyPlanVo plStudyPlanVo) {
        List<PlStudyPlanVo> plStudyPlanVoList = plStudyPlanService.getPlStudyPlanList(plStudyPlanVo);

        return Result.success(plStudyPlanVoList);
    }

    /**
     * 根据id查询详情:学习计划
     */

    @GetMapping("getPlStudyPlanById")
    public Result getPlStudyPlanById(@RequestParam Long id) {
        PlStudyPlanVo plStudyPlan = plStudyPlanService.getPlStudyPlanById(id);
        return Result.success(plStudyPlan);
    }

    /**
     * 根据id删除:学习计划
     */
    @GetMapping("delPlStudyPlan")
    public Result delPlStudyPlan(@RequestParam Long id) {
        plStudyPlanService.delPlStudyPlan(id);
        return Result.success();
    }


    /**
     * 修改:学习计划
     */
    @PostMapping("updatePlStudyPlan")
    public Result updatePlStudyPlan(@RequestBody PlStudyPlanVo plStudyPlanVo) {
        plStudyPlanService.updatePlStudyPlan(plStudyPlanVo);
        return Result.success();

    }
}
